import 'package:account/utils/cache.dart';
import 'package:flutter/material.dart';

import 'main_page.dart';


class LoginApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    GlobalKey key = GlobalKey<FormState>();

    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Form(
            key: key,
            child: Container(
              padding: EdgeInsets.only(left: 30, right: 30),
              child: TextFormField(
                decoration: InputDecoration(hintText: "请输入密码："),
                validator: (v) {
                  return v == Cache.user!.pwd! ? null : "密码错误";
                },
              ),
            ),
          ),
          Text(Cache.user!.pwdTip!),
          TextButton(
              onPressed: () {
                if ((key.currentState as FormState).validate()) {
                  Navigator.pushAndRemoveUntil(
                    context,
                    new MaterialPageRoute(builder: (context) => new MainPageApp()),
                    (route) => false,
                  );
                }
              },
              child: Text("确定"))
        ],
      ),
    );
  }
}
